package com.aimuceliang.aimuceliang.utils.glide;

import android.app.Activity;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.widget.ImageView;

import com.aimuceliang.aimuceliang.utils.StringUtil;
import com.bumptech.glide.Glide;

/**
 * hepeng Created on 2016/10/12.
 * 类名称：
 */
public class GlideLoader {
    /**
     * @param url       url
     * @param object    must be Activity Fragment or Context
     * @param imageView target
     */
    public static void load(String url, Object object, ImageView imageView) {
        if (object == null) {
            return;
        }
        if (!StringUtil.checkStr(url)) {
            return;
        }
        if (object instanceof Fragment) {
            Glide.with(((Fragment) object))
                    .load(url).into(imageView);
        } else if (object instanceof Activity) {
            Glide.with(((Activity) object))
                    .load(url).into(imageView);
        } else if (object instanceof Context) {
            Glide.with(((Context) object))
                    .load(url).into(imageView);
        } else {
            throw new RuntimeException("parameter exception");
        }

    }

}
